package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        File file = new File("./src/main/java/io/ReadStringDemo.java");
        FileInputStream fis = new FileInputStream(file);
        byte[] date = new byte[(int)file.length()];
        fis.read(date);
        //String的构造方法可以将一个字节数组的所有字节按照给定字符集还原成字符串
        String line = new String(date, StandardCharsets.UTF_8);
        System.out.println(line);
        fis.close();
    }
}
